package org.yx.service.sbas.view_base_material;

import com.xiaoleilu.hutool.util.StrUtil;
import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.models.SbasMatDef;
import org.yx.utils.BaseService;

/**
 * 查询物料信息
 * @author zxw
 * @since 2018/03/27
**/
public class SbasViewBaseMaterialService extends BaseService {
	public SbasViewBaseMaterialOut viewBaseMaterial(SbasViewBaseMaterialIn in) throws Exception {
		Query query = new Query(in.getPageIndex(), in.getPageSize());
		query.addFilter("orgCode", in.getUserOrgCode());
		if (!StrUtil.isBlank(in.getMatCode())) {
			query.addFilter("matCode", "like", in.getMatCode() + "%");
		}
		query.addFilter("matStatus", "<>", 'D');

		Page<SbasMatDef> matPage = selectPage(SbasMatDef.class, query);

		SbasViewBaseMaterialOut out = new SbasViewBaseMaterialOut();
		out.setTotalSize(matPage.getTotalSize());
		out.setMatList(matPage.getList());

		return out;
	}
}